package org.electrical.controller.system;

import org.electrical.dao.ElePermissionDao;
import org.electrical.pojo.ElePermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/permission")
@CrossOrigin(value = "*")
public class ElePermissionController {

    @Autowired
    private ElePermissionDao elePermissionDao;

    @RequestMapping("/all")
    @ResponseBody
    public List<ElePermission> all() throws Exception {
        return elePermissionDao.getAll();
    }

    @RequestMapping("/allTwo")
    @ResponseBody
    public List<ElePermission> allTwo() throws Exception {
        return elePermissionDao.getPermission();
    }

    @RequestMapping("/rolePers/{roleId}")
    @ResponseBody
    public List<Integer> searchRolePers(@PathVariable Integer roleId) throws Exception {
        return elePermissionDao.getPerIdByRoleId(roleId);
    }

}
